<template>
	<view class="my">
		<view class="my-header">
			<view class="header-info">
				<text> 账户:{{userInfo.PhoneNumber}} </text>
				<text> 部门:{{ userInfo.Department}}</text>
			</view>
		</view>
		<view class="info-nav" v-for="(item,index) in routerList" :key="index" @click="getPage(item)">
			<view class="nav-left">
				<u--image :src="item.icon" width="50rpx" lazy-load height="50rpx"></u--image>
				<text>{{item.name}}</text>
			</view>
			<view style="display: flex;align-items: center;color: #999;">
				<u-icon name="arrow-right" color="#ccc" bold size="18"></u-icon>
			</view>
		</view>

		<u-popup :show="quitDialog" position="bottom" :style="{ background: '#fff' }">
			<view class="popup-content">
				<text class="popup-title">确认退出吗？</text>
				<view class="popup-buttons">
					<u-button @click="quitDialog = false">取消</u-button>
					<u-button type="primary" @click="getOut" color="#40d4a8">确 认</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				quitDialog: false,
				routerList: [{
						name: '健康评估',
						icon: require('../static/images/1.png'),
						path: '/views/assessment',
					},
					// {
					// 	name: '健康建议',
					// 	icon: require('../static/images/4.png'),
					// 	path: '/views/suggestion',
					// },
					{
						name: '评估记录',
						icon: require('../static/images/3.png'),
						path: '/views/archives',
					},
					{
						name: '退出',
						icon: require('../static/images/2.png'),
						path: ''
					},
				]
			};
		},
		onShow() {
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
		},
		methods: {
			getPage(item) {
				if (!!item.path) {
					uni.navigateTo({
						url: item.path
					})
				} else {
					this.quitDialog = true
				}
			},
			//退出
			getOut() {
				uni.removeStorageSync('userInfo')
				this.quitDialog = false
				uni.navigateTo({
					url: '/pages/login'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my {
		width: 100%;
		height: 100%;
		background-color: #f2f2f2;

		.my-header {
			display: flex;
			width: 100%;
			background-color: #40d4a8;
			padding: 20rpx 40rpx;
			box-sizing: border-box;
			border-radius: 0 0 20rpx 20rpx;
			margin-bottom: 20rpx;

			.header-img {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
				background-color: #f2f2f2;
			}

			.header-info {
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-around;
				height: 120rpx;
				color: #fff;
			}
		}

		.info-nav {
			width: 100%;
			padding: 20rpx 30rpx;
			box-sizing: border-box;
			background-color: #fff;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1rpx solid #f2f2f2;

			.nav-left {
				display: flex;
				align-items: center;

				text {
					margin-left: 20rpx;
					color: #666;
				}
			}

		}

		.popup-content {
			padding: 50rpx 20rpx;
			text-align: center;
			box-sizing: border-box;
		}

		.popup-title {
			font-size: 32rpx;
		}

		.popup-buttons {
			margin-top: 50rpx;
			display: flex;
			justify-content: space-between;
		}
	}
</style>